/* Author: Mark Faust
 *
 * C version of predictor file
*/

#ifndef PREDICTOR_H_SEEN
#define PREDICTOR_H_SEEN

#define TAKEN            true
#define NOT_TAKEN        false

#define PHI              68
#define HISTORY_LENGTH   28
#define NUM_PERCEPTRONS  146
#define NUM_WEIGHTS      28
#define PRIME_NUM        2 
//#define GLOBAL_HISTORY_MASK 0xFFFFF000
#define GLOBAL_HISTORY_MASK 0x0FFFFFFFF
#define GLOBAL_HISTORY_UPDATE_T 0x10000000
#define GLOBAL_HISTORY_UPDATE_N 0xFFFFFFFE
//#define GLOBAL_HISTORY_MASKRU 0x0CC00000
//#define GLOBAL_HISTORY_MASKRL 0x00000CC0

#include <cstddef>
#include <cstring>
#include <inttypes.h>
#include <vector>
#include <cmath>
#include "op_state.h"   // defines op_state_c (architectural state) class 
#include "tread.h"      // defines branch_record_c class

/*
extern int Perceptrons[ NUM_PERCEPTRONS ][ NUM_WEIGHTS ];
extern int BranchHistory[ HISTORY_LENGTH ];
//extern int branch_address;
extern unsigned int branch_address;
extern int index_p;
extern int prediction;
extern unsigned int global_history;
*/


int getPerceptronIndex(); int getPrediction();

class PREDICTOR
{
    public:
        bool get_prediction( const branch_record_c* br, const op_state_c* os );

        void update_predictor( const branch_record_c* br, const op_state_c* os, bool taken );

};

#endif // PREDICTOR_H_SEEN
